#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mid (l+r>>1LL)
#define rep(x,y,z) for(int x=(y);x<=(z);x++)
#define per(x,y,z) for(int x=(y);x>=(z);x--)
#define repn(x) rep(x,1,n)
#define repm(x) rep(x,1,m)
#define e(x) for(int i=h[x],y=to[i];i;i=nxt[i],y=to[i])
#define E(x) for(auto y:p[x])
#define Pi pair<int,int>
#define pb push_back
#define ui unsigned ll
inline int read(){int s=0,w=1;char c=getchar();while(c<48||c>57){if(c=='-')w=-1;c=getchar();}while(c>=48&&c<=57)s=(s<<1)+(s<<3)+c-48,c=getchar();return s*w;}
const int N=1.5e6+5,M=1e6+5,inf=(1LL<<31)-1,mod=1e9+7;
const ll llf=1e18;
inline void add(int &a,int b){((a+=b)>=mod) and (a-=mod);}
inline int Add(int a,int b){return add(a,b),a;}
inline void red(int &a,int b){add(a,mod-b);}
inline int Red(int a,int b){return red(a,b),a;}
inline int mul(int a,int b){return 1LL*a*b%mod;}
inline void Mul(int &a,int b){a=mul(a,b);}
inline int qp(int a,int b){if(!b)return 1;int c=qp(a,b>>1);Mul(c,c);if(b&1)Mul(c,a);return c;}
inline int INV(int x){return qp(x,mod-2);}
int n,k,h[N],to[N<<1],nxt[N<<1],cnt,deg[N];
inline void add_(int a,int b){
    to[++cnt]=b,nxt[cnt]=h[a],h[a]=cnt,deg[a]++;
}
int ct[N],dep[N];
bool v[N];
bool fl=1;
inline void dfs(int x,int fa){
    ct[x]=ct[fa]+v[x],dep[x]=dep[fa]+1;
    if(dep[x]==k)fl&=ct[x]==1;
    e(x)if(y^fa)dfs(y,x);
}
inline void subtask0(){
    int S=(1<<n)-1,ans=0;
    rep(s,0,S){
        repn(i)v[i]=(s>>i-1)&1;
        fl=1;
        repn(x)dfs(x,0);
        ans+=fl;
    }
    puts("YES");
    cout <<ans;
}
inline void Main(){
    n=read(),k=read();
    rep(i,2,n){
        int x=read(),y=read();
        add_(x,y),add_(y,x);
    }
    bool fl=1;
    repn(i)fl&=deg[i]<=2;
    if(fl)return cout <<"YES\n"<<k,void();
    if(n<=18)return subtask0();
}
signed main(){
    freopen("life.in","r",stdin);
    freopen("life.out","w",stdout);
    int T=1;
    while(T--)Main();
    return 0;
}